<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>产品中心</title>
    <meta name="keywords" content="">
    <meta name="description" content="">
    <link href="${ctxPath}/static/admin/css/plugins/sweetalert/sweetalert.css" rel="stylesheet">
    <script src="${ctxPath}/static/admin/js/plugins/sweetalert/sweetalert.min.js"></script>
    <link rel="shortcut icon" href="${ctxPath}/views/admin/favicon.ico"> <link href="${ctxPath}/static/admin/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="${ctxPath}/static/admin/css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <link href="${ctxPath}/static/admin/css/animate.css" rel="stylesheet">
    <link href="${ctxPath}/static/admin/css/style.css?v=4.1.0" rel="stylesheet">
    <style>
    	.center{text-align:center;}
    	#qwer p{ margin:0 auto; font-size:14px; width:10em; white-space:nowrap; text-overflow:ellipsis; -o-text-overflow:ellipsis; overflow:hidden;}
    </style>
</head>

<body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInUp">
        <div class="row">
            <div class="col-sm-12">

                <div class="ibox">
                    <div class="ibox-title">
                        <h5>所有产品</h5>
                        <div class="ibox-tools">
                            <a href="${ctxPath}/product/edit" class="btn btn-primary btn-xs">新增产品</a>
                        </div>
                    </div>
                    <div class="ibox-content">
	                    <form method="post" action="${ctxPath}/product/query">
<!-- 	                        <div class="row m-b-sm m-t-sm"> -->
<!-- 	                            <div class="col-md-1"> -->
<!-- 	                                <button type="button" id="loading-example-btn" class="btn btn-white btn-sm" onclick="reload()"><i class="fa fa-refresh"></i> 刷新</button> -->
<!-- 	                            </div> -->
<!-- 	                            <div class="col-md-3"> -->
<!-- 	                                <div class="input-group"> -->
<!-- 	                                    <input id="goodsName" name="goodsName" value="${goodsName!}" type="text" placeholder="输入商品名称搜索" class="form-control" > <span class="input-group-btn"> -->
<!-- 	                                    <button type="submit" class="btn btn-sm btn-primary"> 搜索</button> </span> -->
<!-- 	                                    &nbsp;<span class="input-group-btn" onclick="empty()"> -->
<!-- 	                                    <button class="btn btn-sm btn-primary" type="button">清空</button> </span> -->
<!-- 	                                </div> -->
<!-- 	                        	</div> -->
<!-- 	                        </div> -->
						</form>
                        <div class="project-list">

                            <table class="table table-hover">
                            	<thead>
                            		<tr>
                            			<th class="center">产品名称</th>
                            			<th class="center">产品大图</th>
                            			<th class="center">产品小图</th>
                            			<th class="center">产品简介</th>
                            			<th class="center">产品类别</th>
                            			<th class="center">排序</th>
                            			<th class="center">操作</th>
                            		</tr>
                            	</thead>
                                <tbody>
	                                <!--# for(var res in data){ -->
	                                    <tr>
	                                        <td class="project-title center">
	                                            <a>${res.product_name!}</a>
	                                        </td>
	                                        <td class="project-people center">
	                                            <p><img alt="image" src="${ctxPath}/down/downProductImg?imgUrl=${res.big_img!}" style="width:80px; height:80px;"></p>
	                                        </td>
	                                        <td class="project-people center">
	                                            <p><img alt="image" src="${ctxPath}/down/downProductImg?imgUrl=${res.small_img!}" style="width:80px; height:80px;"></p>
	                                        </td>
	                                        <td class="project-title">
	                                        	<div id="qwer">
	                                        		<p>${res.product_info!}</p>
	                                        	</div>
	                                        </td>
	                                        <td class="project-title center">
	                                            <p>${res.type_name!}</p>
	                                        </td>
	                                        <td class="project-title center">
	                                            <a>${res.sort!}</a>
	                                        </td>
	                                        <td class="project-actions center">
	                                            <a href="${ctxPath}/product/edit?id=${res.id!}" class="btn btn-white btn-sm">
	                                            	<i class="fa fa-pencil"></i> 编辑 
	                                            </a>
	                                            <a onclick="Delete('${res.id!}')" class="btn btn-white btn-sm">
	                                            	<i class="fa glyphicon glyphicon-cloud"></i> 删除 
	                                            </a>
	                                        </td>
	                                    </tr>
	                               	<!--# } -->
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>

    <!-- 全局js -->
    <script src="${ctxPath}/static/admin/js/jquery.min.js?v=2.1.4"></script>
    <script src="${ctxPath}/static/admin/js/bootstrap.min.js?v=3.3.6"></script>

    <!-- 自定义js -->
    <script src="${ctxPath}/static/admin/js/content.js?v=1.0.0"></script>


    <script>
        $(document).ready(function(){

            $('#loading-example-btn').click(function () {
                btn = $(this);
                simpleLoad(btn, true)
                simpleLoad(btn, false)
            });
        });

        function simpleLoad(btn, state) {
            if (state) {
                btn.children().addClass('fa-spin');
                btn.contents().last().replaceWith(" Loading");
            } else {
                setTimeout(function () {
                    btn.children().removeClass('fa-spin');
                    btn.contents().last().replaceWith(" Refresh");
                }, 2000);
            }
        }
        
        //刷新当前页面
        function reload(){
        	window.location.href="${ctxPath}/goods_manager/query";
        }
        
        //删除当前订单
        function Delete(id){
        	swal({  
                title:"警告",  
                text:"数据删除后将无法恢复,您确定要删除当前数据吗?",  
                type:"warning",  
                showCancelButton:true,
                confirmButtonColor: "#DD6B55",
                closeOnConfirm: false,
                confirmButtonText:"确定",
                cancelButtonText:"取消"
              },function(){
            	  $.post("${ctxPath}/product/delete",{id:id},function(data){
            		  if(data.code == 0){
            			  location.reload();
            		  }else{
            			  swal("操作失败", "数据删除失败!", "error");
            		  }
            	  })
              })
        }
        
        function Editor(gid,title,thumb,unit,go_title,total,status){
        	window.location.href='${ctxPath}/editor_goods/editor?gid='+gid+'&title='+title+'&thumb='+thumb+'&unit='+unit+'&go_title='+go_title+'&total='+total+'&status='+status;
        }
        
        function empty(){
        	$("[name='goodsName']").val("");
        }
     </script>

    </body>
</html>
